package com.ruoyi.front_desk.domain;

/**
 * @author 刘奥旸
 * @version 1.0
 */

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 刘奥旸
 * @version 1.0
 */
@TableName("name_category")
@Data
public class FrontdeskNameCategory implements Serializable {


    private Integer id;


    private String name;


    private Integer parentId;


    private Integer catLevel;


    private Integer isShow;

    private Integer sort;
    @TableField(exist = false)
    private List<FrontdeskNameCategory> childrenCategory;

    // Method to recursively get all ids from childrenCategory

    //测试
    public List<Integer> getAllChildrenIds() {
        List<Integer> ids = new ArrayList<>();
        if (this.childrenCategory != null) {
            for (FrontdeskNameCategory child : this.childrenCategory) {
                ids.add(child.getId());
                ids.addAll(child.getAllChildrenIds());  // Recursively add ids from child categories
            }
        }
        return ids;
    }

    // Constructors, Getters, Setters, toString()...

    // Constructors
    public FrontdeskNameCategory() {
    }

    public FrontdeskNameCategory(String name, Integer parentId, Integer catLevel, Integer isShow, Integer sort) {
        this.name = name;
        this.parentId = parentId;
        this.catLevel = catLevel;
        this.isShow = isShow;
        this.sort = sort;
    }

    // Getters and Setters
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getCatLevel() {
        return catLevel;
    }

    public void setCatLevel(Integer catLevel) {
        this.catLevel = catLevel;
    }

    public Integer getIsShow() {
        return isShow;
    }

    public void setIsShow(Integer isShow) {
        this.isShow = isShow;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    // toString() method
    @Override
    public String toString() {
        return "NameCategory{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", parentId=" + parentId +
                ", catLevel=" + catLevel +
                ", isShow=" + isShow +
                ", sort=" + sort +
                '}';
    }
}
